<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<c:set var="language"
	value="${not empty param.language ? param.language : not empty language ? language : pageContext.request.locale}"
	scope="session" />
<fmt:setLocale value="${language}" />
<fmt:setBundle basename="properties.text" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title><fmt:message key="position.title" /></title>
<link rel="stylesheet" type="text/css" href="/jt-hr-WEB/css/styles.css">
<jsp:useBean id="posBean" class="service.PositionService"
	type="service.PositionService"></jsp:useBean>
<script type="text/javascript" src="position.js"></script>
</head>
<body>
	<form >
            <select id="language" name="language" onchange="submit()">
                <option value="en" ${language == 'en' ? 'selected' : ''}>English</option>
                <option value="de" ${language == 'de' ? 'selected' : ''}>Deutsch</option>
                <option value="ro" ${language == 'ro' ? 'selected' : ''}>Romana</option>
            </select>
    </form>
	<div id="header">
		<div id="img">
			<img class="center" src="/jt-hr-WEB/img/msg_header.jpg"
				height="100px" width="500px" />
			<jsp:include page="/SharedPages/SharedPage.jsp"></jsp:include>
		</div>
	</div>

	<div
		style="width: 75%; margin: 0 auto; margin-top: 10px; border: 3px solid #E6E1E1">

		<h2 align="center">
			<fmt:message key="ptitle" />
		</h2>

		   <jsp:useBean id="operationIsSuccesful" class="java.lang.String" scope="session"/>
    <jsp:setProperty name="operationIsSuccesful" property="*" />
    
	<br>
	<div class="alert-box success" id="succes" style="display:none;margin-left:5%"><span ><fmt:message key="succes" />:</span><fmt:message key="succesm" /></div>
	<br>
	
	<%
		if(operationIsSuccesful=="yes"){
			%>
			<script>
				document.getElementById("succes").style.display='inline';
			</script>
			<% 
		}
	 %>
		<h3 align="center">
			<fmt:message key="activePositions" />
			:
		</h3>
		
		<form action="PositionServiceServlet" method="POST" id="posInactiveNavigation" style="margin-left:10%">
		<input type="submit" value=<fmt:message key="previous" /> name="previousActive" />
		<input type="submit" value=<fmt:message key="next" /> name="nextActive" id="nextActive" style="position:relative;left:73%"/>
		</form>
		
		<table border=1 onclick="activeClick(); activeClickDir()" align="center"
			class="infoTable" style="width:80%;margin: 30px;margin:auto">
			<tr>
			<th><fmt:message key="position" /></th>
			<th><fmt:message key="numberpers" /></th>
			<th><fmt:message key="requirements" /></th>
			<th><fmt:message key="responsabilities" /></th>
			<th><fmt:message key="project" /></th>
			<th><fmt:message key="department" /></th>
			<th></th>
			</tr>
			<c:forEach var="position" items="${allPositions}">
				<tr onclick="populateFields(this)" style="cursor: pointer;text-align:center">
					<td style="display: none;">${position.getIdPosition()}</td>
					<td>${position.getName()}</td>
					<td>${position.getNrPersons()}</td>
					<td style="display: none;">${position.getPositiondescription().getIdPositionDescription()}</td>
					<td>${position.getPositiondescription().getRequirements()}</td>
					<td>${position.getPositiondescription().getResponsabilities()}</td>
					<td>${position.getPositiondescription().getProject()}</td>
					<td>${position.getPositiondescription().getDepartment().getName()}</td>
					<td style="display: none">${position.getPositionstatus().getIdPositionStatus() }</td>
					<td style="display: none;">${position.getPositiondescription().getDepartment().getIdDepartment()}</td>
					<td><a
						href="http://localhost:8080/jt-hr-WEB/positionPages/positionComment?positionId=${position.getIdPosition()}"><fmt:message
								key="comments" /></a></td>
				</tr>
			</c:forEach>
		</table>
		
		

		<c:if
			test="<%=request.getSession().getAttribute("savedUserType").equals("Director General")%>">
			<h3 align="center">
				<fmt:message key="inactivePositions" />
				:
			</h3>
			<form action="PositionServiceServlet" method="POST" id="posInactiveNavigation" style="margin-left:10%">
				<input type="submit" value=<fmt:message key="previous" /> name="previousInactive" />
				<input type="submit" value=<fmt:message key="next" /> name="nextInactive" id="nextInactive" style="position:relative;left:73%"/>
			</form>
			<table border=1 onclick="inactiveClick(); inactiveClickDir()" align="center"
				class="infoTable" style="width:80%;margin: 30px;margin:auto;margin-bottom:30px">
				<tr>
				<th><fmt:message key="position" /></th>
				<th><fmt:message key="numberpers" /></th>
				<th><fmt:message key="requirements" /></th>
				<th><fmt:message key="responsabilities" /></th>
				<th><fmt:message key="project" /></th>
				<th><fmt:message key="department" /></th>
				<th></th>
				</tr>
				<c:forEach var="inactiveposition" items="${allInactivePositions}">
					<tr onclick="populateFields(this);" style="cursor: pointer;text-align:center">
						<td style="display: none;">${inactiveposition.getIdPosition()}</td>
						<td>${inactiveposition.getName()}</td>
						<td>${inactiveposition.getNrPersons()}</td>
						<td style="display: none;">${inactiveposition.getPositiondescription().getIdPositionDescription()}</td>
						<td>${inactiveposition.getPositiondescription().getRequirements()}</td>
						<td>${inactiveposition.getPositiondescription().getResponsabilities()}</td>
						<td>${inactiveposition.getPositiondescription().getProject()}</td>
						<td>${inactiveposition.getPositiondescription().getDepartment().getName()}</td>
						<td style="display: none;">${inactiveposition.getPositionstatus().getIdPositionStatus() }</td>
						<td style="display: none;">${inactiveposition.getPositiondescription().getDepartment().getIdDepartment()}</td>
						<td><a
							href="http://localhost:8080/jt-hr-WEB/positionPages/positionComment?positionId=${inactiveposition.getIdPosition()}"><fmt:message
									key="comments" /></a></td>
					</tr>
				</c:forEach>
			</table>
		
		</c:if>
			<% if (request.getSession().getAttribute("savedUserType").equals("Director HR")||
			request.getSession().getAttribute("savedUserType").equals("Recruiter")||
			request.getSession().getAttribute("savedUserType").equals("Director Department")){
			%>
			<a href="/jt-hr-WEB/directorDepartamentPages/directorDepartamentPage.jsp" id="backbutton"><fmt:message key="back" /></a>
			<%} else {
				if (request.getSession().getAttribute("savedUserType").equals("Director General"))
			%>
			<a href="/jt-hr-WEB/directorGeneralPages/directorGeneralPage.jsp" id="backbutton"><fmt:message key="back" /></a>
			<%} %>
			
			

	
	<td><input type="hidden" name=<fmt:message key="emptyfiled" /> id="emptyfiled"></td>
		<form action="PositionServiceServlet" method="POST" id="positionForm"
			onsubmit="return validate()">
			<table columns="2" align="center" style="margin-bottom:2%">
		<td><input type="hidden" name=<fmt:message key="emptyfilledname" /> id="emptyfilledname"></td>
		<td><input type="hidden" name=<fmt:message key="emptyfillednrpersons" /> id="emptyfillednrpersons"></td>
		<td><input type="hidden" name=<fmt:message key="emptyfilledrequirements" /> id="emptyfilledrequirements"></td>
		<td><input type="hidden" name=<fmt:message key="emptyfilledresponsibilities" /> id="emptyfilledresponsibilities"></td>
		<td><input type="hidden" name=<fmt:message key="emptyfilledproject" /> id="emptyfilledproject"></td>

				<tr>
					<td><fmt:message key="positionName" />:</td>
					<td><input type="text" name="name" id="name"></td>
				</tr>
				<tr>
					<td><fmt:message key="numberpers" />:</td>
					<td><input type="number" name="nrPersons" id="nrPersons" min="1"></td>
				</tr>
				<tr>
					<td><fmt:message key="project" />:</td>
					<td><input type="text" name="project" id="project"></td>
				</tr>
				<tr>
					<td><fmt:message key="department" />:</td>
					<td><select name="department" id="department">
							<c:forEach items="${dep}" var="depart">
								<option value="${depart.idDepartment}">${depart.name}</option>
							</c:forEach>
					</select></td>
				</tr>
				<tr>
					<td><fmt:message key="requirements" />:</td>
					<td><textarea name="requirements" id="requirements"></textarea></td>
					<!-- <td><input type="textarea" name="requirements" id="requirements"></td>-->
				</tr>
				<tr>
					<td><fmt:message key="responsabilities" />:</td>
					<td><textarea name="responsabilities" id="responsabilities"></textarea></td>
					<!-- <td><input type="textarea" name="responsabilities" id="responsabilities"></td> -->
				</tr>

				<div id="message" style="display:none;">${message}</div>	
				<tr>
					<td colspan="2">
					<input type="text" name="idPosition" id="idPosition" style="display: none" > 
					<input type="hidden" name="idDescription" id="idDescription" style="display: none">
					<input type="hidden" name="idPositionStatus" id="idPositionStatus" style="display: none"> 
					<input type="submit" value=<fmt:message key="insert" /> name="insert"> 
					<input type="submit" value=<fmt:message key="edit" /> name="update" id="updateBtn" disabled="disabled">
					<c:if test="<%=request.getSession().getAttribute("savedUserType")
						   .equals("Director General")%>">
						<input type="submit" value=<fmt:message key="remove" />
								name="remove" id="removeBtn" disabled="disabled">
						<input type="submit" value=<fmt:message key="activate" />
								name="activate" id="activateBtn" disabled="disabled">
						</c:if>
						
						<input type="submit" value=<fmt:message key="sendmail" /> name="sendEmail" id="sendEmail" disabled="disabled"> 
						<button type="button" value="export"
						name="export" id="export" onclick="exportFunction();"> Export PDF:</button> <select
						name="expType" id="expType">
							<option value="1"><fmt:message key="position" /></option>
							<option value="2"><fmt:message
									key="positionAndCandidates" /></option>
					</select><br /></td>
				</tr>
			</table>
		</form>
	</div>
<script>
	var lang='<c:out value="${language}"/>';
	select=document.getElementById("language");
	if(lang=="de_DE"||lang=="de"){
		select.options[1].defaultSelected=true;
	}
	else if(lang=="ro_RO"||lang=="ro"){
		select.options[2].defaultSelected=true;
	}
	else {
		select.options[0].defaultSelected=true;
	}

	
</script>
</body>
</html>